import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:qilo/core/constants/app_colors.dart';
import '../../../core/models/teach.dart';
import '../../../core/constants/app_icons.dart';

class ContentItemWidget extends StatelessWidget {
  final Teach teach;
  final VoidCallback onTap;

  const ContentItemWidget({
    super.key,
    required this.teach,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(12.r),
          boxShadow: [
            BoxShadow(
              color: Colors.black.withValues(alpha: 0.2),
              blurRadius: 8,
              offset: const Offset(0, 4),
            ),
          ],
        ),
        child: ClipRRect(
          borderRadius: BorderRadius.circular(12.r),
          child: Stack(
            children: [
              // 背景图片
              Container(
                width: double.infinity,
                height: double.infinity,
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage(teach.coverUrl),
                    fit: BoxFit.cover,
                  ),
                ),
              ),

              // 渐变遮罩
              Container(
                width: double.infinity,
                height: double.infinity,
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: [
                      Colors.transparent,
                      Colors.black.withValues(alpha: 0.3),
                    ],
                  ),
                ),
              ),

              // 播放按钮
              Center(
                child: Icon(
                  MyIcons.iconPlay,
                  color: AppColors.white,
                  size: 56.sp,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
